#include <stdlib.h>
#include <string.h>
#include "iobot.h"
#include "syscall.h"

//reads all input from the keyboard, interprets the scan codes (letters, escape sequences etc.),
//and writes the results to botin.
void iobot_update_input(iobot_t *bot)
{
	if(!bot)
		return;
	if(!bot->focused)
		return;

	unsigned int res1, res2, res3, res4, success = 0;
	char* buffer = (char*)calloc(32, sizeof(char));
	unsigned int i = 0;

	syscall4(SYS_READ, 0, 0, buffer, 32, res1, res2, res3, res4, success)
	for(i = 0; i < 32; i++)
	{
		iobot_process_scancode(bot, buffer[i]);
	}
	free(buffer);
}
